#ifndef __HWICODEC_H__
#define __HWICODEC_H__

#include <stdint.h>
#include <icommon.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    intptr_t		yptr;
    intptr_t		cptr;
    int				i_stride;
    int				i_lines;
} hwicodec_vb_t;

typedef struct {
    hwicodec_vb_t		vb[C_VB_NUM_MAX];
    int				num;
    c_soc_vb_type_t	type;
} hwicodec_vbinfo_t;

typedef struct {
    int				b_use_phy;
    int				i_threads;		/* encode multiple frames in parallel */
    int				gopsize;
    int				i_req_rdnum;
    int				i_devid;
    int				i_csp;			/* CSP of encoded bitstream */
    int				i_width;
    int				i_height;

    /* watermark*/
    int				watermark_en;
    int             H265E_SliceInfoSize;
} hwicodec_h265e_param_t;

typedef struct {
    int				b_tlb;
    int				b_use_phy;
    int				b_user_fenc;
    int				i_threads;		/* encode multiple frames in parallel */
    int				gopsize;
    int				i_req_rdnum;
    int				i_req_rdsnum;
	int				b_mref;
	int				b_buf_share;
    int				b_use_dn;
    int				b_use_ncu;
    int				daisy_chain_en;
    int				i_devid;
    int				i_csp;			/* CSP of encoded bitstream */
    int				i_mb_width;
    int				i_mb_height;
    const uint8_t	**scaling_list; /* could be 12, but we don't allow separate Cb/Cr lists */
    uint8_t			*empty;
    uint32_t			*qp_tab;

    /* Parvate tlb */
    int				private_tlb_flag;
    uint32_t		private_tlb_vbase;
    uint32_t		private_tlb_pbase;

    /* watermark*/
    int				watermark_en;
    int             H264E_SliceInfoSize;
} hwicodec_h264e_param_t;

typedef struct {
    int				b_tlb;
    int				b_use_phy;
    int				b_user_fenc;
    int				i_devid;
    int				i_csp;			/* CSP of encoded bitstream */
    int				i_mb_width;
    int				i_mb_height;
} hwicodec_jpege_param_t;

typedef struct {
    int				b_tlb;
    int				b_use_phy;
    int				i_devid;
    int				i_csp;			/* CSP of encoded bitstream */
    int				i_max_width;
    int				i_max_height;
} hwicodec_jpegd_param_t;

typedef struct {
    int				index;
    int				protocol;
    int				soc;
    union {
        hwicodec_h264e_param_t		h264e_param;
        hwicodec_jpege_param_t		jpege_param;
        hwicodec_jpegd_param_t		jpegd_param;
        hwicodec_h265e_param_t		h265e_param;
    } param;

    /* Log */
    void        (*pf_log)(const char *module, int i_level, const char *psz, va_list);
    const char  *module;
    int         i_log_level;

    /* buf managememt */
    /* must be vitural addr */
    void *(*ckmalloc)(int index, int size, int align);
    void (*ckfree)(int index, void *);
    intptr_t (*ckvirt_to_phys)(intptr_t vaddr);
    intptr_t (*ckphys_to_virt)(intptr_t paddr);
} hwicodec_param_t;

typedef struct {
    uint8_t	roi_en;
    uint8_t	roi_md;
    int8_t	roi_qp;
    uint8_t	roi_lmbx;
    uint8_t	roi_rmbx;
    uint8_t	roi_umby;
    uint8_t	roi_bmby;
} hwicodec_roi_t;

typedef struct {
    intptr_t	yaddr;
    intptr_t	caddr;
    intptr_t	yaddr_pa;
    intptr_t	caddr_pa;
} hwicodec_plane_t;

typedef struct {
    intptr_t	ysize;
    intptr_t	csize;
} hwicodec_plane_size_t;
typedef struct {
    int						    i_frame;
    hwicodec_plane_t			fenc;
    hwicodec_plane_t			fpad;
    hwicodec_plane_size_t		fenc_size;
    hwicodec_plane_t			fref;
    hwicodec_plane_t			fdec;
    int							i_fenc_stride[2];
    int							i_fdec_stride[2];
    int							i_fref_stride[2];
    int						i_csp;
    uint8_t					*fbs;
    int						i_type;
    int						b_fast_mvp;
    hwicodec_roi_t			*proi;
    int						i_qp;
    uint32_t			    *qp_tab;
    int						qp_tab_len;
    int						qp_tab_en;
    int                     cur_scecndt;
    int						i_qp_min;
    int						i_qp_max;
    int						b_deblocking_expand;
    int						b_deblocking_filter;
    int						i_alpha_c0_offset;
    int						i_beta_offset;
    uint8_t					*state;
    uint32_t				cmpx;
    int						i_width;
    int						i_height;
    int						start_mb_x;
    int						start_mb_y;
    int						prev_i_frame;
    int						gopsize;
    int                     i_chroma_cb_qp_offset;
    int                     i_chroma_cr_qp_offset;

    int                     use_dqp_flag;
    int                     dqp_max_depth;
    int                     target_bits;
    uint8_t                 qpg_mode;
    int8_t 		            crp_cu16_offset[8];
    int8_t 		            crp_cu32_offset[8];
    int8_t 		            sas_cu16_offset[7];
    int8_t 		            sas_cu32_offset[7];

    int						priv_size;
    void					*priv;
    int            H265E_SliceInfoSize;
    void           *H265E_SliceInfo;
} hwicodec_io_h265e_t;

typedef struct {

  uint8_t pskip_en;
  uint8_t scl;
  uint8_t hpel_en;
  uint8_t mref_en;
  uint8_t ref_mode;
  uint32_t max_sech_step_i;
  uint32_t max_mvrx_i;
  uint32_t max_mvry_i;
  uint8_t lambda_scale_parameter;
  uint8_t fs_en; //fs function enable
  uint32_t fs_md; //fs step mode, 0: 1, 1: 3
  uint8_t fs_px; //fs period x
  uint8_t fs_py; //fs period y
  uint8_t fs_rx; //fs range x, must be multiples of 3
  uint8_t fs_ry; //fs range y, must be multiples of 3
  uint8_t frm_mv_en; //add a frame level mv
  uint8_t frm_mv_size; //mv enable after x mb, x=2^(size+8)
  uint8_t glb_mv_en;  //global mv enable
  int glb_mvx;  //global mvx value
  int glb_mvy;  //global mvy value
  uint8_t dct8x8_en;
  uint8_t  scaling_list[4][16];
  uint8_t  scaling_list8[2][64];
  int deadzone[9];
  uint8_t deblock;
  uint8_t rotate;
  int8_t alpha_c0_offset;
  int8_t beta_offset;
  uint32_t acmask_mode;
  uint32_t intra_mode_msk;
  uint8_t i_4x4_dis;
  uint8_t i_8x8_dis;
  uint8_t i_16x16_dis;
  uint8_t p_l0_dis;
  uint8_t p_t8_dis;
  uint8_t p_skip_dis;
  uint8_t p_skip_pl0f_dis;
  uint8_t p_skip_pt8f_dis;

  uint8_t cost_bias_en;
  uint8_t cost_bias_i_4x4;
  uint8_t cost_bias_i_8x8;
  uint8_t cost_bias_i_16x16;
  uint8_t cost_bias_p_l0;
  uint8_t cost_bias_p_t8;
  uint8_t cost_bias_p_skip;

  uint8_t intra_lambda_y_bias_en;
  uint8_t intra_lambda_c_bias_en;
  uint8_t intra_lambda_bias_qp0;
  uint8_t intra_lambda_bias_qp1;
  uint8_t intra_lambda_bias_0;
  uint8_t intra_lambda_bias_1;
  uint8_t intra_lambda_bias_2;

  uint8_t chroma_sse_bias_en;
  uint8_t chroma_sse_bias_qp0;
  uint8_t chroma_sse_bias_qp1;
  uint8_t chroma_sse_bias_0;
  uint8_t chroma_sse_bias_1;
  uint8_t chroma_sse_bias_2;

  uint8_t sse_lambda_bias_en;
  uint8_t sse_lambda_bias;
  uint8_t fbc_ep;
  uint8_t jm_lambda2_en;
  uint8_t inter_nei_en;
  uint8_t skip_bias_en;
  uint32_t ysse_thr;
  uint32_t csse_thr;
  uint8_t  dcm_en;
  uint32_t dcm_param;

  uint8_t  sde_prior;
  uint8_t  db_prior;
  uint8_t skip_en;
  int8_t cqp_offset;
  /*mode decision*/
  uint8_t use_intra_in_pframe;
  uint8_t use_fast_mvp;
  uint8_t daisy_chain_en;
  uint8_t curr_thread_id;
  uint8_t qp_tab_mode;
  uint8_t  bs_size_en;
  uint32_t bs_size;
  uint8_t size_mode;
  uint8_t step_mode;
  uint8_t mode_ctrl;
  uint32_t mode_ctrl_param[40];
 /*vmau scaling list*/

  uint8_t info_en;
  uint8_t mvd_sum_all;
  uint8_t mvd_sum_abs;
  uint8_t mv_sum_all;
  uint8_t mv_sum_abs;


  uint8_t  cfg_size_x;
  uint8_t  cfg_size_y;
  uint16_t cfg_iw_thr;

  uint16_t cfg_mvr_thr1;
  uint32_t cfg_mvr_thr2;
  uint32_t cfg_mvr_thr3;


  /*ipred bit&lambda ctrl*/
  uint8_t  mb_mode_val;
  uint8_t  bit_16_en;
  uint8_t  bit_8_en;
  uint8_t  bit_4_en;
  uint8_t  bit_uv_en;
  uint8_t  lamb_16_en;
  uint8_t  lamb_8_en;
  uint8_t  lamb_4_en;
  uint8_t  lamb_uv_en;
  uint8_t  c_16_en;
  uint8_t  c_8_en;
  uint8_t  c_4_en;
  uint8_t  c_uv_en;
  uint8_t  pri_16;
  uint8_t  pri_8;
  uint8_t  pri_4;
  uint8_t  pri_uv;
  uint8_t  ref_neb_4;
  uint8_t  ref_neb_8;
  uint8_t  bit_16[4];
  uint8_t  bit_uv[4];
  uint8_t  bit_4[4];
  uint8_t  bit_8[4];
  uint8_t  lambda_info16;
  uint8_t  lambda_info8;
  uint8_t  lambda_info4;
  uint8_t  lambda_infouv;
  uint8_t  ref_4;
  uint8_t  ref_8;
  uint8_t  const_16[4];
  uint8_t  const_uv[4];
  uint8_t  const_4[4];
  uint8_t  const_8[4];
  uint8_t qp_tab_en;
  uint32_t qp_tab_len;
  uint32_t *qp_tab;
  hwicodec_roi_t roi_info[8];
  uint8_t sas_en;
  uint8_t crp_en;
  uint8_t sas_mthd;
  uint16_t qpg_mb_thd[7];
  int8_t qpg_mbqp_ofst[8];
  uint8_t qpg_flt_thd[5];
  uint8_t mbrc_qpg_sel; //whether use crp/sas qp offset or not, when MB rate control enable.
  /* rate ctrl */
  uint8_t rc_mb_en;
  uint8_t rc_bu_wait_en;// efe chn wait rc qp offset en
  uint8_t rc_mb_wait_en;// efe chn wait rc qp offset en
  uint8_t rc_bu_num;// total basic unit number
  uint16_t rc_bu_size;// mb number in a basic unit
  uint8_t rc_bu_level;// 1:1line 2:2line 3:4line 4:8line 5:16line 6:32line 7:64line
  uint8_t rc_mb_level;// 0:skip 1mb, 1:skip 2mb, 2:skip 4mb, 3:skip 8mb
  int32_t *mb_ref_info;
  int32_t *bu_ref_info;
  uint32_t rc_frm_tbs;
  uint32_t avg_bu_bs;
  uint16_t tar_bs_thd[6];
  int8_t bu_alg0_qpo[6];
  int8_t bu_alg1_qpo[6];
  int8_t mb_cs_qpo[7];
  int8_t mb_top_bs_qpo[2];
  int8_t mb_rinfo_qpo[2];
  uint16_t mb_target_avg_bs[2];
  uint16_t mb_gp_num;
  uint16_t last_bu_size;
  uint8_t rc_bcfg_mode;
  //odma,jrfc,jrfd
  uint8_t jrfcd_flag;
  uint8_t jrfc_enable;
  uint8_t jrfd_enable;
  uint32_t lm_head_total;
  uint32_t cm_head_total;
  //eigen cfg
  uint8_t     mb_mode_use;
  uint8_t     force_i16dc;//ipred
  uint8_t     force_i16;
  uint8_t     refresh_en;
  uint8_t     refresh_mode;
  uint8_t     refresh_bias;
  uint8_t     refresh_cplx_thd;
  uint8_t     cplx_thd_sel;
  uint8_t     diff_cplx_sel;
  uint8_t     diff_thd_sel;
  uint8_t     i16dc_cplx_thd;
  uint8_t     i16dc_qp_base;
  uint8_t     i16dc_qp_sel;
  uint8_t     i16_qp_base;
  uint8_t     i16_qp_sel;
  uint8_t     diff_cplx_thd;
  uint8_t     diff_qp_base[2];
  uint8_t     diff_qp_sel[2];
  uint8_t     cplx_thd_idx[24];
  uint8_t     cplx_thd[8];
  uint16_t    diff_thd_base[3];
  uint16_t    diff_thd_ofst[3];
  uint8_t     sas_eigen_en;
  uint8_t     crp_eigen_en;
  uint8_t     sas_eigen_dump;
  uint8_t     crp_eigen_dump;
  //ifa
  uint8_t     rrs_en;
  uint8_t     rrs_dump_en;
  uint8_t     rrs_uv_en;
  uint8_t     rrs_size_y; //0: 4, 1: 8, 2: 12, 3: 16
  uint8_t     rrs_size_c; //0: 4, 1: 8
  uint16_t    rrs_thrd_y; //threshold
  uint16_t    rrs_thrd_u;
  uint16_t    rrs_thrd_v;
  int frame_width;
  int frame_height;
  uint8_t first_mby;
  uint8_t last_mby;  //for multi-slice

  /* motion */

  uint8_t frm_re[4];
  uint8_t qpel_en;

}rc_slice_h264_t21;

typedef struct {
    int			     i_frame;
    hwicodec_plane_t	     fenc;
    hwicodec_plane_t         fpad;
    hwicodec_plane_size_t    fenc_size;
    hwicodec_plane_t	     fref;
    hwicodec_plane_t	     fmref;
    hwicodec_plane_t	     fdec;
    int			     i_fenc_stride[2];
    int			     i_csp;
    uint8_t		    *fbs;
    int			     is_use_ncu;
    int			     ncu_middate_size;
    uint32_t		     ncu_out_p;
    uint32_t		     ncu_middate_p;
    int			     i_mb_width;
    int			     i_mb_height;
    int			     i_type;
    int			     b_fast_mvp;
    uint8_t		     *state;
    int			     priv_size;
    void		     *priv;
    uint32_t		     cmpx;
    uint8_t pskip_en;
  uint8_t scl;
  uint8_t hpel_en;
  uint8_t mref_en;
  uint8_t ref_mode;
  uint32_t max_sech_step_i;
  uint32_t max_mvrx_i;
  uint32_t max_mvry_i;
  uint8_t lambda_scale_parameter;
  uint8_t fs_en; //fs function enable
  uint32_t fs_md; //fs step mode, 0: 1, 1: 3
  uint8_t fs_px; //fs period x
  uint8_t fs_py; //fs period y
  uint8_t fs_rx; //fs range x, must be multiples of 3
  uint8_t fs_ry; //fs range y, must be multiples of 3
  uint8_t frm_mv_en; //add a frame level mv
  uint8_t frm_mv_size; //mv enable after x mb, x=2^(size+8)
  uint8_t glb_mv_en;  //global mv enable
  int glb_mvx;  //global mvx value
  int glb_mvy;  //global mvy value
  uint8_t                  me_step_en; //auto-modify max step number
  uint8_t                  me_step_0; //step number threshold 0
  uint8_t                  me_step_1; //step number threshold 1
  uint8_t dct8x8_en;
  uint8_t  scaling_list[4][16];
  uint8_t  scaling_list8[2][64];
  int deadzone[9];
  uint8_t deblock;
  uint8_t rotate;
  int8_t alpha_c0_offset;
  int8_t beta_offset;
  uint32_t acmask_mode;
  uint32_t intra_mode_msk;
  uint8_t i_4x4_dis;
  uint8_t i_8x8_dis;
  uint8_t i_16x16_dis;
  uint8_t p_l0_dis;
  uint8_t p_t8_dis;
  uint8_t p_skip_dis;
  uint8_t p_skip_pl0f_dis;
  uint8_t p_skip_pt8f_dis;

  uint8_t cost_bias_en;
  uint8_t cost_bias_i_4x4;
  uint8_t cost_bias_i_8x8;
  uint8_t cost_bias_i_16x16;
  uint8_t cost_bias_p_l0;
  uint8_t cost_bias_p_t8;
  uint8_t cost_bias_p_skip;

  uint8_t intra_lambda_y_bias_en;
  uint8_t intra_lambda_c_bias_en;
  uint8_t intra_lambda_bias_qp0;
  uint8_t intra_lambda_bias_qp1;
  uint8_t intra_lambda_bias_0;
  uint8_t intra_lambda_bias_1;
  uint8_t intra_lambda_bias_2;

  uint8_t chroma_sse_bias_en;
  uint8_t chroma_sse_bias_qp0;
  uint8_t chroma_sse_bias_qp1;
  uint8_t chroma_sse_bias_0;
  uint8_t chroma_sse_bias_1;
  uint8_t chroma_sse_bias_2;

  uint8_t sse_lambda_bias_en;
  uint8_t sse_lambda_bias;
  uint8_t fbc_ep;
  uint8_t jm_lambda2_en;
  uint8_t inter_nei_en;
  uint8_t skip_bias_en;
  uint32_t ysse_thr;
  uint32_t csse_thr;
  uint8_t  dcm_en;
  uint32_t dcm_param;

  uint8_t  sde_prior;
  uint8_t  db_prior;
  uint8_t skip_en;
  int8_t cqp_offset;
  /*mode decision*/
  uint8_t use_intra_in_pframe;
  uint8_t use_fast_mvp;
  uint8_t daisy_chain_en;
  uint8_t curr_thread_id;
  uint8_t qp_tab_mode;
  uint8_t  bs_size_en;
  uint32_t bs_size;
  uint8_t size_mode;
  uint8_t step_mode;
  uint8_t mode_ctrl;
  uint32_t mode_ctrl_param[40];
 /*vmau scaling list*/

  uint8_t info_en;
  uint8_t mvd_sum_all;
  uint8_t mvd_sum_abs;
  uint8_t mv_sum_all;
  uint8_t mv_sum_abs;


  uint8_t  cfg_size_x;
  uint8_t  cfg_size_y;
  uint16_t cfg_iw_thr;

  uint16_t cfg_mvr_thr1;
  uint32_t cfg_mvr_thr2;
  uint32_t cfg_mvr_thr3;


  /*ipred bit&lambda ctrl*/
  uint8_t  mb_mode_val;
  uint8_t  bit_16_en;
  uint8_t  bit_8_en;
  uint8_t  bit_4_en;
  uint8_t  bit_uv_en;
  uint8_t  lamb_16_en;
  uint8_t  lamb_8_en;
  uint8_t  lamb_4_en;
  uint8_t  lamb_uv_en;
  uint8_t  c_16_en;
  uint8_t  c_8_en;
  uint8_t  c_4_en;
  uint8_t  c_uv_en;
  uint8_t  pri_16;
  uint8_t  pri_8;
  uint8_t  pri_4;
  uint8_t  pri_uv;
  uint8_t  ref_neb_4;
  uint8_t  ref_neb_8;
  uint8_t  bit_16[4];
  uint8_t  bit_uv[4];
  uint8_t  bit_4[4];
  uint8_t  bit_8[4];
  uint8_t  lambda_info16;
  uint8_t  lambda_info8;
  uint8_t  lambda_info4;
  uint8_t  lambda_infouv;
  uint8_t  ref_4;
  uint8_t  ref_8;
  uint8_t  const_16[4];
  uint8_t  const_uv[4];
  uint8_t  const_4[4];
  uint8_t  const_8[4];
  uint8_t qp_tab_en;
  uint32_t qp_tab_len;
  uint32_t *qp_tab;
  //hwicodec_roi_t roi_info[8];
  uint8_t sas_en;
  uint8_t crp_en;
  uint8_t sas_mthd;
  uint16_t qpg_mb_thd[7];
  int8_t qpg_mbqp_ofst[8];
  uint8_t qpg_flt_thd[5];
  uint8_t mbrc_qpg_sel; //whether use crp/sas qp offset or not, when MB rate control enable.
  /* rate ctrl */
  uint8_t rc_mb_en;
  uint8_t rc_bu_wait_en;// efe chn wait rc qp offset en
  uint8_t rc_mb_wait_en;// efe chn wait rc qp offset en
  uint8_t rc_bu_num;// total basic unit number
  uint16_t rc_bu_size;// mb number in a basic unit
  uint8_t rc_bu_level;// 1:1line 2:2line 3:4line 4:8line 5:16line 6:32line 7:64line
  uint8_t rc_mb_level;// 0:skip 1mb, 1:skip 2mb, 2:skip 4mb, 3:skip 8mb
  int32_t *mb_ref_info;
  int32_t *bu_ref_info;
  uint32_t rc_frm_tbs;
  uint32_t avg_bu_bs;
  uint16_t tar_bs_thd[6];
  int8_t bu_alg0_qpo[6];
  int8_t bu_alg1_qpo[6];
  int8_t mb_cs_qpo[7];
  int8_t mb_top_bs_qpo[2];
  int8_t mb_rinfo_qpo[2];
  uint16_t mb_target_avg_bs[2];
  uint16_t mb_gp_num;
  uint16_t last_bu_size;
  uint8_t rc_bcfg_mode;
  //odma,jrfc,jrfd
  uint8_t jrfcd_flag;
  uint8_t jrfc_enable;
  uint8_t jrfd_enable;
  uint32_t lm_head_total;
  uint32_t cm_head_total;
  //eigen cfg
  uint8_t     mb_mode_use;
  uint32_t    *mb_mode_info;
  uint8_t     force_i16dc;//ipred
  uint8_t     force_i16;
  uint8_t     refresh_en;
  uint8_t     refresh_mode;
  uint8_t     refresh_bias;
  uint8_t     refresh_cplx_thd;
  uint8_t     cplx_thd_sel;
  uint8_t     diff_cplx_sel;
  uint8_t     diff_thd_sel;
  uint8_t     i16dc_cplx_thd;
  uint8_t     i16dc_qp_base;
  uint8_t     i16dc_qp_sel;
  uint8_t     i16_qp_base;
  uint8_t     i16_qp_sel;
  uint8_t     diff_cplx_thd;
  uint8_t     diff_qp_base[2];
  uint8_t     diff_qp_sel[2];
  uint8_t     cplx_thd_idx[24];
  uint8_t     cplx_thd[8];
  uint16_t    diff_thd_base[3];
  uint16_t    diff_thd_ofst[3];
  uint8_t     sas_eigen_en;
  uint8_t     crp_eigen_en;
  uint8_t     sas_eigen_dump;
  uint8_t     crp_eigen_dump;
  //ifa
  uint8_t     rrs_en;
  uint8_t     rrs_dump_en;
  uint8_t     rrs_uv_en;
  uint8_t     rrs_size_y; //0: 4, 1: 8, 2: 12, 3: 16
  uint8_t     rrs_size_c; //0: 4, 1: 8
  uint16_t    rrs_thrd_y; //threshold
  uint16_t    rrs_thrd_u;
  uint16_t    rrs_thrd_v;
  int frame_width;
  int frame_height;
  uint8_t first_mby;
  uint8_t last_mby;  //for multi-slice

  /* motion */

  uint8_t frm_re[4];
  uint8_t qpel_en;
//reseve part
    int						b_deblocking_filter;
    int						b_deblocking_expand;
    int						i_alpha_c0_offset;
    int						i_beta_offset;
    int						start_mb_x;
    int						start_mb_y;
    int						i_qp;
    int						i_qp_min;
    int						i_qp_max;
 int						prev_i_frame;
    int						gopsize;
    int                     cur_scecndt;
    hwicodec_roi_t			*proi;
    int                     i_chroma_qp_offset;
    uint32_t frame_target_bs;
    double ref_mad_all;
    uint32_t qpgMode;
    int8_t crp_mb_ofst[8];
    int8_t sas_mb_ofst[7];

//    rc_slice_h264_t21 *slice_info;
/*
    int						qp_tab_len;
    int						qp_tab_en;





    uint8_t cost_bias_en;//ingenic
    uint8_t cost_bias_i_4x4;
    uint8_t cost_bias_i_16x16;
    uint8_t cost_bias_p_l0;
    uint8_t cost_bias_p_skip;
    uint8_t inter_nei_en;
    uint8_t skip_bias_en;
    //VPU_RC_QPG_MODE_S_T30 qpgMode;
    */
  //skin
    uint8_t     skin_dt_en;
    uint8_t     skin_lvl;
    uint8_t     skin_cnt_thd;
    uint8_t     skin_pxlu_thd[3][2];
    uint8_t     skin_pxlv_thd[3][2];
    int8_t      skin_qp_ofst[4];
    uint8_t     mult_factor[3];
    uint8_t     shift_factor[3][3];//[0][]:0.4, [1][]:0.6, [2][]: 5.1
    uint16_t    skin_ofst[4];//[0]: 1.5, [1]:0.4, [2]:0.6, [3]: 5.1
    uint8_t     ncu_mov_en;
    uint32_t    ncu_move_len;
    uint32_t    *ncu_move_info;
  //buf-share
    uint8_t     buf_share_en;
    uint8_t     buf_share_size;
    uint32_t    frame_idx;
    uint32_t    *emc_qpt_va;
    uint32_t    *emc_rc_va;
    uint32_t    *emc_cpx_va;
    uint32_t    *emc_mod_va;
    uint32_t    *emc_ncu_va;
    uint32_t    *emc_sad_va;
    int         H264E_SliceInfoSize;
    void        *H264E_SliceInfo;
} hwicodec_io_h264e_t;

typedef struct {
    hwicodec_plane_t			fenc;
    hwicodec_plane_size_t		fenc_size;
    int							i_fenc_stride[2];
    uint8_t					*fbs;
    int						i_ql;
    bool                    user_ql_en;
    uint32_t                qmem_table[128];
    uint32_t                frame_width;
    uint32_t                frame_height;
} hwicodec_io_jpege_t;

typedef struct {
    hwicodec_plane_t			fenc;
    uint8_t					*fbs;
    int						*regs;
    int						*hea;  // -> BASE mem (base.dat) - 9 bits array
    int						*heb; // -> SYMB mem (symb.dat) - 8 bits array
    int						*huffmin; // -> min values (min.dat)
    int						(*qt)[64]; // QT (qdtable.dat)

    int						(*hcode)[256]; // -> Huffman simulation mem values (hmem.sim)
    int						(*hlen)[256]; // -> Huffman simulation mem values (hmem.sim)
    int						*huffenc;
} hwicodec_io_jpegd_t;

typedef struct {
    union {
        hwicodec_io_h264e_t		h264e;
        hwicodec_io_jpege_t		jpege;
        hwicodec_io_jpegd_t		jpegd;
        hwicodec_io_h265e_t		h265e;
    } protocol;
    int							bslen;
} hwicodec_io_t;

/* you can define the hwicodec_t context which you need the user to provide to you */
typedef struct hwicodec hwicodec_t;

extern hwicodec_t *hwicodec_init(hwicodec_param_t *param);
extern int hwicodec_process(hwicodec_t *h, hwicodec_io_t *input);
extern void hwicodec_deinit(hwicodec_t *h);
extern int hwicodec_request_vbinfo(hwicodec_t *h, hwicodec_vbinfo_t **vbinfo, int *vbnum);
extern void hwicodec_release_vbinfo(hwicodec_t *h, hwicodec_vbinfo_t *vbinfo);

#ifdef CONFIG_SINGLE_BS
#include <semaphore.h>
extern sem_t bsbufsem;
#define hwicodec_bsbuf_lock() sem_wait(&bsbufsem)
#define hwicodec_bsbuf_unlock() sem_post(&bsbufsem)
#endif

#ifdef __cplusplus
}
#endif

#endif /* __HWICODEC_H__ */
